#include "items.h"


/* Example code from jwalsh
vector<item*> Items;
Items[0] = new Armor;
Items[1] = new Weapon;

....

for( int i = 0; i < Items.size; i++ )
{
Weapon* pTempWeapon = dynamic_cast<Weapon*>( Items[i] );
if( pTempWeapon)
{
....
}
else // null
}

#include <fstream>
#include <string>
#include <vector>

struct Object {
int itsid;
std::string itsword;
Object(int anid, const std::string& aword) : itsid(anid), itsword(aword) {}
};

using namespace std;

int main() {
vector<Object> objects;

ifstream fin("test.csv");

string text;
int id;

// While we are able to consume any leading whitespace (this will also
// skip past the newline left by a previous read if any), read up until a 
// comma into text, and subsequently read into a number:
while (fin >> ws && getline(fin, text, ',') && fin >> id ) {
// Create an object with those values and put it in the vector.
objects.push_back(Object(id, text));
}

// display them.
for (int i=0; i < objects.size; ++i) {
Object& o = objects[i];
cout << "Its word: " << o.itsword << " and its id: " << o.itsid << endl;
}
}

*/

cItem::cItem()
{
	mName.clear(); mDescription.clear(); mType = -1; mValue = mLevelRequired = mCollection = mXpWorth = 0;
	isTwoHanded = isHeavy = isConsumeable = isLocked = false; isSellable = true;
}

cItem::cItem( string name, string desc, int type, int value, bool twoh, bool heavy, bool sell, bool consumeable, bool locked )
{
	mName = name; mDescription = desc; isConsumeable = consumeable; mType = type; mValue = value; isTwoHanded = twoh; 
	isHeavy = heavy; isSellable = sell; isLocked = locked;
}

cItem::~cItem()
{
}


bool cItem::Use(string sAction)
{
	const char *tmp = sAction.c_str();
	switch(mType)
	{
	case 0: // food
		switch(*tmp)
		{
			// add code based on actions	
		}
		break;
	case 1: // health potion
		switch(*tmp)
		{
			// add code based on actions	
		}
		break;
	case 2: // mana potion
		switch(*tmp)
		{
			// add code based on actions	
		}
		break;
	case 3: // magic potion
		switch(*tmp)
		{
			// add code based on actions	
		}
		break;
	case 4: // valuable
		switch(*tmp)
		{
			// add code based on actions	
		}
		break;
	
	case 10: // chest
		switch(*tmp)
		{
			// add code based on actions	
		}
		break;
	case 11: // unique
		switch(*tmp)
		{
			// add code based on actions	
		}
		break;
	case 12: // quest
		switch(*tmp)
		{
			// add code based on actions	
		}
		break;
	default:
		error("Invalid item type in cItem. Name: "+mName);
		break;
	}
	return false; // shouldn't get here...
}